import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, Router, NavigationEnd} from '@angular/router';
import {SystemConfigService} from '@core/services/system-config.service';
import { filter } from 'rxjs/operators';

@Component({
  selector: 'app-first-page',
  templateUrl: './first-page.component.html',
  styleUrls: ['./first-page.component.less']
})
export class FirstPageComponent implements OnInit {
  dataSet = [
    {
      key: '1',
      info: '厕所信息填报',
      infoNum: 32,
      updateTime: '2018-12-16 15:32',
      introduction: '有变化填报'
    },
    {
      key: '2',
      info: '厕所信息填报',
      infoNum: 32,
      updateTime: '2018-12-16 15:32',
      introduction: '有变化填报'
    },
    {
      key: '3',
      info: '厕所信息填报',
      infoNum: 32,
      updateTime: '2018-12-16 15:32',
      introduction: '有变化填报'
    },
    {
      key: '4',
      info: '厕所信息填报',
      infoNum: 32,
      updateTime: '2018-12-16 15:32',
      introduction: '有变化填报'
    },
    {
      key: '4',
      info: '厕所信息填报',
      infoNum: 32,
      updateTime: '2018-12-16 15:32',
      introduction: '有变化填报'
    },
    {
      key: '4',
      info: '厕所信息填报',
      infoNum: 32,
      updateTime: '2018-12-16 15:32',
      introduction: '有变化填报'
    },
    {
      key: '4',
      info: '厕所信息填报',
      infoNum: 32,
      updateTime: '2018-12-16 15:32',
      introduction: '有变化填报'
    },
    {
      key: '4',
      info: '厕所信息填报',
      infoNum: 32,
      updateTime: '2018-12-16 15:32',
      introduction: '有变化填报'
    },
    {
      key: '4',
      info: '厕所信息填报',
      infoNum: 32,
      updateTime: '2018-12-16 15:32',
      introduction: '有变化填报'
    },
    {
      key: '4',
      info: '厕所信息填报',
      infoNum: 32,
      updateTime: '2018-12-16 15:32',
      introduction: '有变化填报'
    },

    {
      key: '4',
      info: '厕所信息填报',
      infoNum: 32,
      updateTime: '2018-12-16 15:32',
      introduction: '有变化填报'
    },
    {
      key: '4',
      info: '厕所信息填报',
      infoNum: 32,
      updateTime: '2018-12-16 15:32',
      introduction: '有变化填报'
    },
    {
      key: '4',
      info: '厕所信息填报',
      infoNum: 32,
      updateTime: '2018-12-16 15:32',
      introduction: '有变化填报'
    }
  ];

  public productId: void;

  constructor(private activatedRoute: ActivatedRoute, private router: Router, private systemService: SystemConfigService) {
    activatedRoute.queryParams.subscribe(queryParams => {
      this.productId = queryParams.scenicName;
      console.log(this.productId);
    });
  }

  ngOnInit() {
    this.router.events
      .pipe(filter(event => event instanceof NavigationEnd))
      .subscribe(event => {
        this.productId = this.activatedRoute.snapshot.queryParams.scenicName;
      });
  }

  // 当有参数传递时调用此方法
  jumpWithStatus(name: string) {
    console.log(name);
    this.router.navigate(['basicInfoDetail'], {
      queryParams: { scenicName: name }
    });
  }
}
